package com.yf.course.modules.course.dto.response;

import com.yf.course.modules.course.dto.CourseFileLearnDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
* <p>
* 课件学习数据传输类
* </p>
*
* @author 聪明笨狗
* @since 2020-12-17 11:28
*/
@Data
@ApiModel(value="课件学习记录响应类", description="课件学习记录响应类")
public class CourseFileLearnRespDTO extends CourseFileLearnDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "课程名称")
    private String courseName;

    @ApiModelProperty(value = "文件名称")
    private String fileName;

    @ApiModelProperty(value = "要求学习秒数")
    private Integer needLearn;

    /**
     * 获取进度
     * @return
     */
    public Long getProcess(){
        if(needLearn == null || needLearn==0){
            return 100L;
        }

        if(getLearnSec()==null || getLearnSec()==0){
            return 0L;
        }

        long process = getLearnSec()*100 / needLearn;
        return process>100?100: process;
    }

}
